const pool = require("@/db");
const table = require("@/db/table");

// 根据account查询用户
exports.getMemberByAccount = async ({ account, openid, id }) => {
  return await pool
    .select("*")
    .from(table.MEMBER)
    .where("id", id, "eq", "ifHave")
    .where("account", account, "eq", "ifHave")
    .where("openid", openid, "eq", "ifHave")
    .queryRow();
};

// 绑定微信
exports.bindWxUser = async ({ id, openid, session_key }) => {
  return await pool
    .update(table.MEMBER)
    .column("openid", openid)
    .column("session_key", session_key)
    .where("id", id)
    .execute();
};
